package com.ShoppingLover;

public class GoodsInfor {
    //设置属性的私有访问权限
    private String goodsNum; //商品编号
    private String goodsName; //商品名称
    private GoodsType goodsTy; //所属类别
    private int goodsCount; //商品数量
    private double goodsPrice; //商品价格


    //通过公有的get,set方法实现对属性的访问
    public String getGoodsNum() {
        return goodsNum;
    }
    public void setGoodsNum(String goodsNum) {
        this.goodsNum = goodsNum;
    }
    public String getGoodsName() {
        return goodsName;
    }
    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }
    public GoodsType getGoodsTy() {
        return goodsTy;
    }
    public void setGt(GoodsType goodsTy) {
        this.goodsTy = goodsTy;
    }
    public int getGoodsCount() {
        return goodsCount;
    }
    public void setGoodsCount(int goodsCount) {
        if(goodsCount>0){
            this.goodsCount = goodsCount;
        }else{
            System.out.println("库存数量异常,请联系管理员");
        }

    }
    public double getGoodsPrice() {
        return goodsPrice;
    }
    public void setGoodsPrice(double goodsPrice) {
        this.goodsPrice = goodsPrice;
    }


    //无参构造方法
    public GoodsInfor() {
    }
    //有参构造方法,实现属性赋值
    public GoodsInfor(String goodsName,GoodsType goodsTy, int goodsCount, double goodsPrice) {
        this.goodsName = goodsName;
        this.goodsTy =goodsTy;
        this.setGoodsCount(goodsCount);
        this.goodsPrice = goodsPrice;

    }

    //盘点的方法
    public void show(){
        System.out.println("商品名称:"+goodsName);
        System.out.println("所属类别:"+goodsTy.getTypeName());
        System.out.println("商品售价:"+goodsPrice);
        System.out.println("库存数量:"+goodsCount);
        System.out.println("商品总价:"+goodsPrice*goodsCount);
    }

}